<?php

use yii\db\Migration;

class m170328_014734_alter_teacher extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }

    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%teacher}}', 'parent_id', 'integer(11) default 0 comment \'班主任id\'');
            $this->addColumn('{{%teacher}}', 'cate_id', 'integer(11) default 0 comment \'班主任所属分类 1 益智  2 音乐  3  形体\'');
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%teacher}}', 'parent_id');
            $this->dropColumn('{{%teacher}}', 'cate_id');
        }
    }
}
